home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part2 / 17386 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  3.2 KB

  1. Path: cc.iu.net!news
  2. From: Rick Flick <rflick@iu.net>
  3. Newsgroups: comp.lang.c++
  4. Subject: help porting 16 bit to 32 bit application with vc++
  5. Date: Mon, 15 Apr 1996 13:36:42 -0500
  6. Organization: XLVision
  7. Message-ID: <3172973A.1192@iu.net>
  8. NNTP-Posting-Host: netport-44.iu.net
  9. Mime-Version: 1.0
  10. Content-Type: text/plain; charset=us-ascii
  11. Content-Transfer-Encoding: 7bit
  12. X-Mailer: Mozilla 2.0 (Win95; I)
  13.  
  14. Help!
  15. I am trying to get the following code to work in 32 bit mode using Microsoft Visual C++ (4.1)
  16. compiler.  It compiles and runs fine using the 16 bit compiler (2.1 I think), but in the 32 bit
  17. complier, I get the following error at the two lines that are noted:
  18. error C2443: operand size conflict
  19.  
  20. I am not an assembly coder so I really have no idea how this piece works, but it does
  21. (under 16 bits)!  It compiles and runs just fine in 16 bits.
  22.  
  23. I just started with XLVision and as of yet do not have my own e-mail address.  If you could
  24. help, please respond to : melharti@xlvision.com and/or the newsgroup.
  25.  
  26. here is the offending code:
  27.  
  28. thanks for your help!
  29. -jor
  30. Jordan Thompson
  31. XLVision
  32. (407)589-7331
  33.  
  34.  
  35. WORD FAR change_int_intr( VOID )
  36. {
  37.     WORD    rt;
  38.  
  39.     rt = 0;
  40.     _disable();                        //Disable interrupt.
  41.     _asm{
  42.         push    DS
  43. error-> mov     AX, DS
  44.         mov     ES, AX
  45.         mov     DI, OFFSET reg_st      ;;ES:DI points to register structure.
  46.         mov     AX, CS
  47.         mov     DS, AX
  48.         mov     SI, OFFSET new_intr_proc;;DS:SI points to new int. procedure.
  49. error-> mov     AX, 303h
  50.         int     31h                    ;;Allocate real mode Seg:Off (in CX:DX).
  51.         jc      error
  52.         pop     DS
  53.         mov     DLLgv_new_intr_seg, CX ;;Set the Seg:Off to 2 global variables.
  54.         mov     DLLgv_new_intr_off, DX
  55.  
  56.         mov     BL, DLLgv_hooked_intr  ;;Set BL to the 0Dh.
  57.         mov     AX, 200h               ;;Get the int. vector (in CX:DX).
  58.         int     31h
  59.         jc      error
  60.  
  61.         mov     DLLgv_old_intr_seg, CX ;;Save old vector (in CX:DX).
  62.         mov     DLLgv_old_intr_off, DX
  63.  
  64.         mov     BL, DLLgv_hooked_intr  ;;Set BL to the 0Dh.
  65.         mov     CX, DLLgv_new_intr_seg
  66.         mov     DX, DLLgv_new_intr_off
  67.         mov     AX, 201h               ;;Set new vector to the int.
  68.         int     31h
  69.         jc      error
  70.         jmp     ok
  71.     error:
  72.         mov     rt, 1
  73.     ok:
  74.         }
  75.     _enable();                         //Enable interrupt.
  76.  
  77.     return( rt );
  78. }
  79.  
  80.  
  81.                 //return 0: sucessful
  82.                 //       1: restore error
  83. WORD FAR restore_int_intr( VOID )
  84. {
  85.     WORD    rt;
  86.  
  87.     rt = 0;
  88.     _disable();                        //Disable interrupt.
  89.     _asm{
  90.         mov     CX, DLLgv_old_intr_seg  ;;Set the old int.# vector to CX:DX.
  91.         mov     DX, DLLgv_old_intr_off
  92.         mov     BL, DLLgv_hooked_intr   ;;Set 0Dh to BL to be restored.
  93.         mov     AX, 201h                ;;Restore the interrupt.
  94.         int     31h
  95.         jc      error
  96.  
  97.         mov     CX, DLLgv_new_intr_seg  ;;Set real mode Seg:Off to CX:DX.
  98.         mov     DX, DLLgv_new_intr_off
  99.         mov     AX, 304h                ;;Release the real mode Seg:Off.
  100.         int     31h
  101.         jmp     ok
  102.     error:
  103.         mov     rt, 1
  104.     ok:
  105.         }
  106.     _enable();                         //Enable interrupt.
  107.     return( rt );
  108. }
  109.